/**
 * <copyright>
 * </copyright>
 *
 */
package de.sabram.upb.specs.lido.impl;

import de.sabram.upb.specs.lido.ExpandOpt;
import de.sabram.upb.specs.lido.LidoPackage;
import de.sabram.upb.specs.lido.RemoteClause;
import de.sabram.upb.specs.lido.Shield;
import de.sabram.upb.specs.lido.Subtree;
import de.sabram.upb.specs.lido.SymOcc;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Subtree</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.sabram.upb.specs.lido.impl.SubtreeImpl#getRemoteClause <em>Remote Clause</em>}</li>
 *   <li>{@link de.sabram.upb.specs.lido.impl.SubtreeImpl#getShield <em>Shield</em>}</li>
 *   <li>{@link de.sabram.upb.specs.lido.impl.SubtreeImpl#getExpandOpt <em>Expand Opt</em>}</li>
 *   <li>{@link de.sabram.upb.specs.lido.impl.SubtreeImpl#getSymOcc <em>Sym Occ</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SubtreeImpl extends RemoteExpressionImpl implements Subtree
{
  /**
   * The cached value of the '{@link #getRemoteClause() <em>Remote Clause</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRemoteClause()
   * @generated
   * @ordered
   */
  protected RemoteClause remoteClause;

  /**
   * The cached value of the '{@link #getShield() <em>Shield</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getShield()
   * @generated
   * @ordered
   */
  protected Shield shield;

  /**
   * The cached value of the '{@link #getExpandOpt() <em>Expand Opt</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getExpandOpt()
   * @generated
   * @ordered
   */
  protected ExpandOpt expandOpt;

  /**
   * The cached value of the '{@link #getSymOcc() <em>Sym Occ</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSymOcc()
   * @generated
   * @ordered
   */
  protected SymOcc symOcc;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected SubtreeImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return LidoPackage.Literals.SUBTREE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public RemoteClause getRemoteClause()
  {
    return remoteClause;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetRemoteClause(RemoteClause newRemoteClause, NotificationChain msgs)
  {
    RemoteClause oldRemoteClause = remoteClause;
    remoteClause = newRemoteClause;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LidoPackage.SUBTREE__REMOTE_CLAUSE, oldRemoteClause, newRemoteClause);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setRemoteClause(RemoteClause newRemoteClause)
  {
    if (newRemoteClause != remoteClause)
    {
      NotificationChain msgs = null;
      if (remoteClause != null)
        msgs = ((InternalEObject)remoteClause).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LidoPackage.SUBTREE__REMOTE_CLAUSE, null, msgs);
      if (newRemoteClause != null)
        msgs = ((InternalEObject)newRemoteClause).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LidoPackage.SUBTREE__REMOTE_CLAUSE, null, msgs);
      msgs = basicSetRemoteClause(newRemoteClause, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.SUBTREE__REMOTE_CLAUSE, newRemoteClause, newRemoteClause));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Shield getShield()
  {
    return shield;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetShield(Shield newShield, NotificationChain msgs)
  {
    Shield oldShield = shield;
    shield = newShield;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LidoPackage.SUBTREE__SHIELD, oldShield, newShield);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setShield(Shield newShield)
  {
    if (newShield != shield)
    {
      NotificationChain msgs = null;
      if (shield != null)
        msgs = ((InternalEObject)shield).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LidoPackage.SUBTREE__SHIELD, null, msgs);
      if (newShield != null)
        msgs = ((InternalEObject)newShield).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LidoPackage.SUBTREE__SHIELD, null, msgs);
      msgs = basicSetShield(newShield, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.SUBTREE__SHIELD, newShield, newShield));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ExpandOpt getExpandOpt()
  {
    return expandOpt;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetExpandOpt(ExpandOpt newExpandOpt, NotificationChain msgs)
  {
    ExpandOpt oldExpandOpt = expandOpt;
    expandOpt = newExpandOpt;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LidoPackage.SUBTREE__EXPAND_OPT, oldExpandOpt, newExpandOpt);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setExpandOpt(ExpandOpt newExpandOpt)
  {
    if (newExpandOpt != expandOpt)
    {
      NotificationChain msgs = null;
      if (expandOpt != null)
        msgs = ((InternalEObject)expandOpt).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LidoPackage.SUBTREE__EXPAND_OPT, null, msgs);
      if (newExpandOpt != null)
        msgs = ((InternalEObject)newExpandOpt).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LidoPackage.SUBTREE__EXPAND_OPT, null, msgs);
      msgs = basicSetExpandOpt(newExpandOpt, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.SUBTREE__EXPAND_OPT, newExpandOpt, newExpandOpt));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public SymOcc getSymOcc()
  {
    return symOcc;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetSymOcc(SymOcc newSymOcc, NotificationChain msgs)
  {
    SymOcc oldSymOcc = symOcc;
    symOcc = newSymOcc;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LidoPackage.SUBTREE__SYM_OCC, oldSymOcc, newSymOcc);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSymOcc(SymOcc newSymOcc)
  {
    if (newSymOcc != symOcc)
    {
      NotificationChain msgs = null;
      if (symOcc != null)
        msgs = ((InternalEObject)symOcc).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - LidoPackage.SUBTREE__SYM_OCC, null, msgs);
      if (newSymOcc != null)
        msgs = ((InternalEObject)newSymOcc).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - LidoPackage.SUBTREE__SYM_OCC, null, msgs);
      msgs = basicSetSymOcc(newSymOcc, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LidoPackage.SUBTREE__SYM_OCC, newSymOcc, newSymOcc));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case LidoPackage.SUBTREE__REMOTE_CLAUSE:
        return basicSetRemoteClause(null, msgs);
      case LidoPackage.SUBTREE__SHIELD:
        return basicSetShield(null, msgs);
      case LidoPackage.SUBTREE__EXPAND_OPT:
        return basicSetExpandOpt(null, msgs);
      case LidoPackage.SUBTREE__SYM_OCC:
        return basicSetSymOcc(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case LidoPackage.SUBTREE__REMOTE_CLAUSE:
        return getRemoteClause();
      case LidoPackage.SUBTREE__SHIELD:
        return getShield();
      case LidoPackage.SUBTREE__EXPAND_OPT:
        return getExpandOpt();
      case LidoPackage.SUBTREE__SYM_OCC:
        return getSymOcc();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case LidoPackage.SUBTREE__REMOTE_CLAUSE:
        setRemoteClause((RemoteClause)newValue);
        return;
      case LidoPackage.SUBTREE__SHIELD:
        setShield((Shield)newValue);
        return;
      case LidoPackage.SUBTREE__EXPAND_OPT:
        setExpandOpt((ExpandOpt)newValue);
        return;
      case LidoPackage.SUBTREE__SYM_OCC:
        setSymOcc((SymOcc)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case LidoPackage.SUBTREE__REMOTE_CLAUSE:
        setRemoteClause((RemoteClause)null);
        return;
      case LidoPackage.SUBTREE__SHIELD:
        setShield((Shield)null);
        return;
      case LidoPackage.SUBTREE__EXPAND_OPT:
        setExpandOpt((ExpandOpt)null);
        return;
      case LidoPackage.SUBTREE__SYM_OCC:
        setSymOcc((SymOcc)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case LidoPackage.SUBTREE__REMOTE_CLAUSE:
        return remoteClause != null;
      case LidoPackage.SUBTREE__SHIELD:
        return shield != null;
      case LidoPackage.SUBTREE__EXPAND_OPT:
        return expandOpt != null;
      case LidoPackage.SUBTREE__SYM_OCC:
        return symOcc != null;
    }
    return super.eIsSet(featureID);
  }

} //SubtreeImpl
